﻿Public Class frmCourseQuery
    Private Sub frmCourseQuery_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Dim icount As Integer
        cboWhere.Items.Clear()
        cboWhere.Items.Add("课程编号")
        cboWhere.Items.Add("课程名称")
        cboWhere.SelectedIndex = 0
        txtSQL = "SELECT 课程编号,课程名称,课程分类,学分,课程描述"
        txtSQL = txtSQL & " FROM 课程 "
        icount = ExecuteSQL(txtSQL, ErrorMsg)
        DataGridView1.DataSource = DBSet.Tables.Item(0)
    End Sub

    Private Sub cmdQuery_Click(sender As Object, e As EventArgs) Handles cmdQuery.Click

        If Trim(txtWord.Text) = "" Then
            MsgBox("请输入检索词")
            Exit Sub
        End If
        txtSQL = "SELECT 课程编号,课程名称,课程类别,学分,课程描述"
        txtSQL = txtSQL & " FROM 课程 "
        If cboWhere.Text = "课程编号" Then
            txtSQL = txtSQL & "WHERE 课程编号='" & Trim(txtWord.Text) & "'"
        End If
        If cboWhere.Text = "课程名称" Then
            txtSQL = txtSQL & "WHERE 课程名称 like '%" & Trim(txtWord.Text) & "%'"
        End If

        Dim icount As Integer
        icount = ExecuteSQL(txtSQL, ErrorMsg)
        DataGridView1.DataSource = DBSet.Tables.Item(0)
    End Sub

    Private Sub cmdExit_Click(sender As Object, e As EventArgs) Handles cmdExit.Click
        Me.Close()
    End Sub
End Class